home *** CD-ROM | disk | FTP | other *** search
- /*==================================================================
- File: LinuxZString.h
-
- Contains: Linux-specific parsing for ZStrings.
- Okay, not really linux specific, but maybe X specific.
-
- Written by: Jeremy Alves
-
- Copyright: 2000-2001 Connectix Corporation
-
- This source has been placed into the public domain by
- Connectix Corporation. You have the right to modify,
- distribute or use this code without any legal limitations
- or finanicial/licensing requirements. Connectix is not
- liable for any problems that result from the use of this
- code.
-
- If you have comments, feedback, questions, or would like
- to submit bug fixes or updates to this code, please email
- opensource@connectix.com.
- ==================================================================*/
-
-
- #include "LinuxZString.h"
- #include "ZStringDictionary.h"
-
- /*------------------------------------------------------------------
- Initialize [static]
-
- This static method instantiates the singleton classes
- for tracking ZStrings.
- ------------------------------------------------------------------*/
-
- void
- LinuxZString::Initialize()
- {
- new ZStringDictionary;
- new LinuxZStringParser;
- }
-
-
- /*------------------------------------------------------------------
- TearDown [static]
- ------------------------------------------------------------------*/
-
- void
- LinuxZString::TearDown()
- {
- delete &ZStringDictionary::GetZStringDictionary();
- delete &ZStringParser::GetZStringParser();
- }
-
-
- /*------------------------------------------------------------------
- GetNamedCString [static]
- ------------------------------------------------------------------*/
-
- const char *
- LinuxZString::GetNamedCString(
- const char * inNamedString)
- {
- ZString namedString;
-
- namedString.GetNamedString(inNamedString);
- return (namedString.GetCString());
- }
-
-
- /*------------------------------------------------------------------
- GetTagReplacement
-
- This function is probably all wrong,
- at might depend on the codepage we're using.
- ------------------------------------------------------------------*/
-
- Z_UInt16
- LinuxZStringParser::GetTagReplacement(
- ZStringTagID inTagID,
- char * outReplacement)
- {
- // By default, all tags are one character.
- UInt16 tagSize = 1;
-
- if (outReplacement != NULL)
- {
- static const char sTagReplacements[] = {
- '\0', // kTagIDInvalid
- '\xc6', // kZTag_AElig,
- '\xc1', // kZTag_Aacute,
- '\xc2', // kZTag_Acirc,
- '\xc0', // kZTag_Agrave,
- '\xc5', // kZTag_Aring,
- '\xc3', // kZTag_Atilde,
- '\xc4', // kZTag_Auml,
- '\xc7', // kZTag_Ccedil,
- '\xc9', // kZTag_Eacute,
- '\xca', // kZTag_Ecirc,
- '\xc8', // kZTag_Egrave,
- '\xcb', // kZTag_Euml,
- '\xcd', // kZTag_Iacute,
- '\xce', // kZTag_Icirc,
- '\xcc', // kZTag_Igrave,
- '\xcf', // kZTag_Iuml,
- '\xd1', // kZTag_Ntilde,
- '\xd3', // kZTag_Oacute,
- '\xd4', // kZTag_Ocirc,
- '\xd2', // kZTag_Ograve,
- '\xd8', // kZTag_Oslash,
- '\xd5', // kZTag_Otilde,
- '\xd6', // kZTag_Ouml,
- '\xda', // kZTag_Uacute,
- '\xdb', // kZTag_Ucirc,
- '\xd9', // kZTag_Ugrave,
- '\xdc', // kZTag_Uuml,
- '\xe1', // kZTag_aacute,
- '\xe2', // kZTag_acirc,
- '\xe6', // kZTag_aelig,
- '\xe0', // kZTag_agrave,
- '\x26', // kZTag_amp,
- '\xe5', // kZTag_aring,
- '\xe3', // kZTag_atilde,
- '\xe4', // kZTag_auml,
- '\x27', // kZTag_bdquo,
- '\xb7', // kZTag_bull,
- '\xe7', // kZTag_ccedil,
- '\x9b', // kZTag_cent,
- '\xa9', // kZTag_copy,
- '\xe9', // kZTag_eacute,
- '\xea', // kZTag_ecirc,
- '\xe8', // kZTag_egrave,
- '\xeb', // kZTag_euml,
- '\x3E', // kZTag_gt,
- '\x85', // kZTag_hellip,
- '\xed', // kZTag_iacute,
- '\xee', // kZTag_icirc,
- '\xa1', // kZTag_iexcl,
- '\xed', // kZTag_igrave,
- '\xbf', // kZTag_iquest,
- '\xef', // kZTag_iuml,
- '\x93', // kZTag_ldquo,
- '\x91', // kZTag_lsquo,
- '\x3C', // kZTag_lt,
- '\x2d', // kZTag_mdash,
- '\xb5', // kZTag_micro,
- //FIX ME
- //'\~', // kZTag_nbsp,
- '\x20', // kZTag_ndash,
- '\xf1', // kZTag_ntilde,
- '\xf3', // kZTag_oacute,
- '\xf4', // kZTag_ocirc,
- '\xf2', // kZTag_ograve,
- '\xf8', // kZTag_oslash,
- '\xf5', // kZTag_otilde,
- '\xf6', // kZTag_ouml,
- '\x14', // kZTag_para,
- '\xe3', // kZTag_pi,
- '\x23', // kZTag_pound,
- '\x94', // kZTag_rdquo,
- '\x99', // kZTag_reg,
- '\x00', // kZTag_replace
- '\x92', // kZTag_rsquo,
- '\x82', // kZTag_sbquo,
- '\xdf', // kZTag_szlig,
- '\xae', // kZTag_trade,
- '\xfa', // kZTag_uacute,
- '\xfb', // kZTag_ucirc,
- '\xf9', // kZTag_ugrave,
- '\xfc', // kZTag_uuml,
- '\x9d', // kZTag_yen,
- '\xff', // kZTag_yuml
- '\x0d' // kZTag_br
- };
-
- check(inTagID > kZTag_Invalid && inTagID < sizeof(sTagReplacements)/sizeof(char));
- check(inTagID != kZTag_replace);
-
- // fill in the equivalent
- *outReplacement = sTagReplacements[inTagID];
- if (inTagID == kZTag_hellip)
- strcpy(outReplacement, "...");
- }
-
- if (inTagID == kZTag_hellip)
- tagSize = strlen("...");
-
- return tagSize;
- }
-
-
-